﻿using MyHelper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace weighing
{
    public class RuntimeData
    {

        private static RuntimeData? instance;

        public static RuntimeData Instance
        {
            get
            {
                instance ??= new RuntimeData();
                return instance;
            }
        }

        private List<CarInfoVo>? cars;
        public List<CarInfoVo>? TempCars
        {
            get
            {
                cars ??= CarDao.Instance.SelectAll()?.Select((i) => { return new CarInfoVo(i); }).ToList();
                return cars;
            }
        }

        private List<CompanyVo>? companys;
        public List<CompanyVo>? TempCompany
        {
            get
            {
                companys ??= CompanyDao.Instance.SelectAll()?.Select((i) => { return new CompanyVo(i); }).ToList();
                return companys;
            }
        }

        private List<MaterialVo>? meteials;
        public List<MaterialVo>? TempMaterial
        {
            get
            {
                meteials ??= MaterialDao.Instance.SelectAll()?.Select(
                          (i) => { return new MaterialVo(i); }).ToList();
                return meteials;
            }
        }


        public void Clear()
        {
            companys?.Clear();
            meteials?.Clear();
            cars?.Clear();
        }
    }
}
